package net.sourceforge.wurfl.core.handlers.matchers.strategy.trie.node;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;

/**
 * An implementation of the TrieNode in which every node represents a character 
 * @author WURFL-PRO SRL, Rome, Italy
 */
public class CharTrieNode implements TrieNode  {

	private Character prefix;
	private Map subTrie;
	private Integer tolerance;
	private Object value;
	
	
	public CharTrieNode(Character prefix) {
		this.prefix = prefix;
		this.subTrie = new TreeMap();
		this.tolerance = new Integer(0);
	}
	
	public Object getPrefix() {
		return prefix;
	}
	public void setPrefix(Character prefix) {
		this.prefix = prefix;
	}
	public Map getSubTrie() {
		return subTrie;
	}
	public void setSubTrie(Map subTrie) {
		this.subTrie = subTrie;
	}
	public Integer getTolerance() {
		return tolerance;
	}
	public void setTolerance(Integer tolerance) {
		this.tolerance = tolerance;
	}
	public Object getValue() {
		return value;
	}
	public void setValue(Object value) {
		this.value = value;
	}
	
	public String toString() {
		System.err.println("--------------");
		
		Collection subTrie = this.getSubTrie().values();
		for (Iterator it = subTrie.iterator();it.hasNext();) {
			CharTrieNode currentNode = (CharTrieNode) it.next();
			System.err.println(currentNode.getPrefix()+" -> "+currentNode.getValue() + " (son of '" + this.getPrefix() + "' ) ");
			currentNode.toString();
		}
		return super.toString();
	}
	

}
